package org.zhadoop.stream.cql.semanticanalyzer.parser.context;

import java.util.List;

import org.zhadoop.stream.cql.exception.SemanticAnalyzerException;
import org.zhadoop.stream.cql.semanticanalyzer.analyzecontext.expressiondesc.ExpressionDescribe;
import org.zhadoop.stream.cql.semanticanalyzer.parsecontextreplacer.ParseContextReplacer;
import org.zhadoop.stream.cql.semanticanalyzer.parsecontextwalker.ParseContextWalker;

import com.google.common.base.Joiner;
import com.google.common.collect.Lists;

/**
 * binary 表达式语法遍历
 * 
 * @author zwd
 *
 */
public class BinaryExpressionContext extends BaseExpressionParseContext {

	// BitExpressionContext
	private BaseExpressionParseContext bitExpression;

	// RelationExpressionContext
	private List<BaseExpressionParseContext> relationExpression;

	public BinaryExpressionContext() {
		relationExpression = Lists.newArrayList();
	}

	public BaseExpressionParseContext getBitExpression() {
		return bitExpression;
	}


	public void setBitExpression(BaseExpressionParseContext bitExpression) {
		this.bitExpression = bitExpression;
	}


	public List<BaseExpressionParseContext> getRelationExpression() {
		return relationExpression;
	}


	public void setRelationExpression(List<BaseExpressionParseContext> relationExpression) {
		this.relationExpression = relationExpression;
	}


	@Override
	public void walkChildAndReplace(ParseContextReplacer replacer) {
		// TODO Auto-generated method stub

	}

	@Override
	protected ExpressionDescribe createExpressionDesc() throws SemanticAnalyzerException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append(bitExpression.toString());
		if (relationExpression.size() > 0) {
			sb.append(" ");
		}
		sb.append(Joiner.on(" ").join(relationExpression));
		return sb.toString();
	}
	
	

	@Override
	protected void walkChild(ParseContextWalker walker) {
		// TODO Auto-generated method stub

	}

}
